import Vue from "vue";
import VueRouter from "vue-router";


Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
import Layout from '@/layout';

export const constantRoutes =[
	{
	  path: '',
	  component: Layout,
	  redirect: 'index',
	  children: [
	    {
	      path: 'index',
	      component: (resolve) => require(['@/views/index'], resolve),
	      name: '首页',
	      meta: { title: '首页', icon: 'el-icon-s-tools', noCache: true, affix: true }
	    },
		
	  ]
	},
	{
	  path: '/login',
	  component: (resolve) => require(['@/views/login'], resolve),
	  hidden: true
	},
	{
		path: '/404',
		component: (resolve) => require(['@/views/error/404'], resolve),
		hidden: true
	  },
	{
		path:'/redirect',
		component:Layout,
		hidden:true,
		children:[
			{
			path:'/redirect/:path(.*)',
			component: (resolve) => require(['@/views/redirect'], resolve)
		      }
	    ]
	},
]

export default new VueRouter({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

